﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Model;
using Core.UnitOfWork;

namespace Core.Repository
{
    public class NodeRepository<TEntity> : Repository<TEntity>, INodeRepository<TEntity>
        where TEntity :class, INode<TEntity>
    {
        public NodeRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
        {

        }

        public override void Add(TEntity entity)
        {
            base.Add(entity);            
        }

        public override void Update(TEntity entity)
        {
            base.Update(entity);
        }

        public override void Delete(TEntity entity)
        {
            base.Delete(entity);
        }



        public virtual TEntity GetParent(int parentId)
        {
            return this.Get(parentId);
        }

        public virtual IList<TEntity> GetChildren(int parentId)
        {
            return this.Find(c => c.ParentId == parentId);
        }
    }
}
